package com.walkline.dianping.dao;

import org.json.me.JSONArray;
import org.json.me.JSONException;
import org.json.me.JSONObject;

import com.walkline.dianping.DianpingException;
import com.walkline.dianping.DianpingSDK;
import com.walkline.dianping.inf.Business;
import com.walkline.dianping.inf.SingleDeal;
import com.walkline.util.Function;

public class DianpingBusiness extends DianpingObject implements Business
{
	private String _name = "";
	private int _id = 0;
	private String _city = "";
	private String _address = "";
	private double _latitude = 0;
	private double _longitude = 0;
	private String _url = "";
	private String _html5_url = "";

	public DianpingBusiness(DianpingSDK dianping, JSONObject jsonObject) throws DianpingException
	{
		super(dianping, jsonObject);

		try {
			JSONObject business = jsonObject;

			if (business != null)
			{
				_name = business.optString("name");
				_id = business.optInt("id");
				_city = business.optString("city");
				_address = business.optString("address");
				_latitude = business.getDouble("latitude");
				_longitude = business.getDouble("longitude");
				_url = business.optString("url");
				_html5_url = business.optString("h5_url");
			}
		} catch (JSONException e) {Function.errorDialog(e.toString());}
	}

	//商户名
	public String getName() {return _name;}

	//商户ID
	public int getID() {return _id;}

	//商户城市
	public String getCity() {return _city;}

	//商户地址
	public String getAddress() {return _address;}

	//商户纬度
	public double getLatitude() {return _latitude;}

	//商户经度
	public double getLongitude() {return _longitude;}

	//商户页链接
	public String getURL() {return _url;}

	//商户页HTML5链接
	public String getHTML5URL() {return _html5_url;}
}